foreach L in "" L {
	foreach b in "" "b0" {
		if "`b'"=="" local bo = "birth_order"
		if "`b'"=="b0" local bo = "birth_order0"

		capture drop bo_cap
		gen bo_cap = `bo'
		replace bo_cap = 4 if `bo'>4

		foreach x in pred pred0 {
			capture drop agiz_taxsim_unadj
			gen long agiz_taxsim_unadj = floor(`x'_agiz_unadj/100)*100

			capture drop _m_`x'taxsim`b'

			if "`L'"=="L" {
				rename mstat mstat0
				rename Lmstat mstat
			}

			replace mstat=1 if mstat==.
			merge m:1 year agiz_taxsim_unadj mstat bo_cap using ${supp_data}/dtax_taxsim_slim, keep(match master) keepusing( deitc_taxsim dtax_taxsim nc_eitc) gen(_m_`x'taxsim`b')

			if "`L'"=="L" {
				rename mstat Lmstat
				rename mstat0 mstat
			}

			rename deitc_taxsim `x'_deitc_taxsim`b'`L'
			rename dtax_taxsim `x'_dtax_taxsim`b'`L'

			gen i_`x'_eitcany_taxsim`b'`L' = (nc_eitc>0 | `x'_agiz==0) if `k1'=`bo'
			replace i_`x'_eitcany_taxsim`b'`L' = . if nc_eitc==.
			replace i_`x'_eitcany_taxsim`b'`L' = 0 if year<=1975

			capture drop agiz_taxsim nc_eitc
		}
	}
}
